
#pragma once
#include <QStandardItemModel>
#include <Qt>
#include <interactive_markers/interactive_marker_server.hpp>
#include <list>


using visualization_msgs::msg::InteractiveMarker;
using interactive_markers::InteractiveMarkerServer;


namespace rviz_custom_plugins
{

namespace viewmodels
{

class PointModel : public QStandardItemModel {
    Q_OBJECT

public:
    explicit PointModel(QObject *parent = nullptr) ;

    Qt::ItemFlags flags(const QModelIndex& index) const override;

    bool insertItem(int row, InteractiveMarker& intMarker);

    void removeItem(int row);

    void handleMarkerFeedback(InteractiveMarkerServer::FeedbackConstSharedPtr feedback);

    InteractiveMarker& getRowItem(int row);
    int getItemRow(QString& markerName);

    std::list<InteractiveMarker>& getMarkers();
signals:
    void markerEditUpdated(const InteractiveMarker& marker);
    void itemOrderUpdated(int row, std::list<InteractiveMarker>& markers);

private:

    inline static const QString ROW = "row";
    // 存储真实数据
    std::list<InteractiveMarker> markers;

    void handleItemsReorder(int row);

};

}

}
